<article class="cl pd-20">
    {if $indexTips}
    <div class="row">
        <div class="Huialert Huialert-danger"><i class="Hui-iconfont">&#xe6a6;</i>{$indexTips|raw}</div>
    </div>
    {/if}
    <div class="row">
        <div class="col-lg-8">
            <div class="row">
                <!--快捷方式-->
                <div class="col-12 col-sm-6">
                    <div class="card">
                        <div class="card-header ui-sortable-handle">
                            <h3 class="card-title"><i class="Hui-iconfont">&#xe61b;</i>快捷方式</h3>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">
                            <!-- <a class="btn btn-app" href="{:url('/sys/system/index')}">
                                <div><i class="Hui-iconfont">&#xe62e;</i></div>
                                <span>系统设置</span>
                            </a> -->
                            {foreach $indexButton as $button}
                            <a class="btn btn-app" href="/sys/{$button.url}">
                                <div><i class="Hui-iconfont">{$button.icon|raw}</i></div>
                                <span>{$button.name}</span>
                            </a>
                            {/foreach}
                            <a class="btn btn-app" onclick="addButton();">
                                <div><i class="Hui-iconfont">&#xe600;</i></div>
                                <span>管理快捷方式</span>
                            </a>
                        </div>
                        <!-- /.card-body -->
                    </div>
                    <!-- /.card -->
                </div>
                <!--数据统计-->
                <div class="col-12 col-sm-6">
                    <div class="card">
                        <div class="card-header ui-sortable-handle">
                            <h3 class="card-title"><i class="Hui-iconfont">&#xe621;</i> 数据统计</h3>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body cl">
                            <div class="row">
                                <div class="col-6 f-l">
                                    <div class="inner">
                                        <h4>文章总数</h4>
                                        <p id="countArticle">0</p>
                                    </div>
                                </div>
                                <div class="col-6 f-l">
                                    <div class="inner">
                                        <h4>行业应用总数</h4>
                                        <p id="countIndustry">0</p>
                                    </div>
                                </div>
                                <div class="col-6 f-l">
                                    <div class="inner">
                                        <h4>待处理留言</h4>
                                        <p id="countGuestBook">0</p>
                                    </div>
                                </div>
                                <!-- ./col -->
                            </div>
                        </div>
                        <!-- /.card-body -->
                    </div>
                    <!-- /.card -->
                </div>
            </div>
            <div class="row">
                <!--系统信息-->
                <div class="col-12">
                    <div class="card">
                        <div class="card-header ui-sortable-handle">
                            <h3 class="card-title"><i class="Hui-iconfont">&#xe72b;</i> 系统信息</h3>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body" style="display: block;">
                            <table class="table table-striped">
                                <tr>
                                    <td>网站域名</td>
                                    <td>{$config.url}</td>
                                </tr>
                                <tr>
                                    <td>网站目录</td>
                                    <td>{$config.document_root}</td>
                                </tr>
                                <tr>
                                    <td>服务器操作系统</td>
                                    <td>{$config.server_os}</td>
                                </tr>
                                <tr>
                                    <td>服务器端口</td>
                                    <td>{$config.server_port}</td>
                                </tr>
                                <tr>
                                    <td>服务器IP</td>
                                    <td>{$config.server_ip}</td>
                                </tr>
                                <tr>
                                    <td>WEB运行环境</td>
                                    <td>{$config.server_soft}</td>
                                </tr>
                                <tr>
                                    <td>MySQL数据库版本</td>
                                    <td>{$config.mysql_version}</td>
                                </tr>
                                <tr>
                                    <td>运行PHP版本</td>
                                    <td>{$config.php_version}</td>
                                </tr>
                                <tr>
                                    <td>最大上传限制</td>
                                    <td>{$config.max_upload_size}</td>
                                </tr>
                                <tr>
                                    <td>已用空间</td>
                                    <td>
                                        <span id="spaceInfo">
                                            <img src="/static/images/loading.gif" alt="正在载入" class="mid"> Loading...
                                        </span>
                                        <span class="ml-50 c-blue">
                                            <a href="javascript:clearCache();">清除缓存</a>
                                        </span>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <!-- /.card-body -->
                    </div>
                    <!-- /.card -->
                </div>
            </div>
        </div>
        <div class="col-lg-4">
            <div class="row">
                <!--版本信息-->
                <div class="col-12">
                    <div class="card">
                        <div class="card-header ui-sortable-handle">
                            <h3 class="card-title"><i class="Hui-iconfont">&#xe6cd;</i> 版本信息</h3>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body" style="display: block;">
                            <table class="table  table-border table-bordered">
                                <tr>
                                    <td class="text-center">当前版本</td>
                                    <td>FYHSCMS V{$sys_version}</td>
                                </tr>
                                <tr>
                                    <td class="text-center">基于框架</td>
                                    <td>ThinkPHP6 + Hui.Admin</td>
                                </tr>
                                <tr>

                                </tr>
                                <tr>
                                    <td>
                                        <a href="https://www.kancloud.cn/manual/thinkphp6_0" target="_blank"
                                            class="btn btn-flat btn-success " rel="noopener"
                                            title="ThinkPHP6 开发手册">ThinkPHP6 开发手册</a>
                                    </td>
                                    <td>
                                        <a href="http://h-ui.net/Hui-overview.shtml" target="_blank"
                                            class="btn btn-flat btn-secondary " rel="noopener" title="Hui.Admin 文档">
                                            Hui.Admin 文档</a>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <!-- /.card-body -->
                    </div>
                    <!-- /.card -->
                </div>
            </div>
            <div class="row">
                <!--版本信息-->
                <div class="col-12">
                    <div class="card">
                        <div class="card-header ui-sortable-handle">
                            <h3 class="card-title"><i class="Hui-iconfont">&#xe6cd;</i>登录记录</h3>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">
                            <table class="table table-border table-bordered table-bg mt-20">
                                <thead>
                                    <tr>
                                        <th colspan="4" scope="col">最近登陆记录</th>
                                    </tr>
                                    <tr>
                                        <th class='text-c' width="10%">序号</th>
                                        <th class='text-c' width="40%">登陆时间</th>
                                        <th class='text-c' width="30%">登陆IP</th>
                                        <th class='text-c' width="20%">状态</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {foreach $dataLogin as $key=>$val}
                                    <tr>
                                        <td class='text-c'>{$key + 1}</td>
                                        <td>{$val.logintime}</td>
                                        <td>{$val.loginip}</td>
                                        <td>{$val.status ? "fail" : "success"}</td>
                                    </tr>
                                    {/foreach}
                                </tbody>
                            </table>
                        </div>
                        <!-- /.card-body -->
                    </div>
                    <!-- /.card -->
                </div>
            </div>
        </div>
    </div>
</article>
<style>
    #dialog {
        position: fixed;
        height: 360px;
        width: 600px;
        background: #FFFFFF;
        z-index: 5;
        left: 30%;
        border: 1px solid gray;
        top: 25%;
        display: none;
    }

    #cancel {
        border: 0px none #FFECEC;
        background: #999999;
        color: #FFFFFF;
        padding: 5px 15px;
        position: absolute;
        top: 8px;
        right: 100px;
    }

    #cancel:hover {
        background: #AAAAAA;
    }
</style>
<div id="dialog">
    <div style="position: absolute;height: 40px;width: 100%;background: #FFFFFF;border-bottom: 1px solid gray;">
        <span style="position: absolute;left: 10px;top: 10px;color: gray;" class="dialog-tilte">选择快捷方式</span>
        <img src="/static/images/X.png"
            style="height: 25px;width: 25px;position: absolute;right: 10px;top: 10px;cursor: pointer;"
            onclick="f_cancel()" />
    </div>
    <div class="tab" style="margin-left:30px;margin-top:40px;">
        <form id="form-save" method="post" action="">
            <div class="row cl mt-20">
                <div class="skin-minimal">
                    {foreach $menuList as $value}
                    <div class="check-box" style="width: 200px;">
                        <input type="checkbox" id="checkbox-1" name="checkbox[]" value="{$value.menuid}" {if
                            $value.method==1}checked{/if}>
                        <label for="checkbox-1">{$value.name}</label>
                    </div>
                    {/foreach}
                </div>
            </div>
            <div class="row cl" style="margin-top:10px;">
                <div class="formControls col-sm-6 col-xs-8 col-sm-offset-4 col-xs-offset-4">
                    <button type="button" class="btn btn-success radius" onclick="saveIndexButton()">保存</button>
                </div>
            </div>
        </form>
    </div>
</div>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    $(document).ready(function () {
        usedSpace();
        countArticle();
        countIndustry();
        countGuestBook();
    })

    function countArticle() {
        $.post('/sys/index/countArticle', function (res) {
            if (res.code == 0) {
                $("#countArticle").html(res.data.nums);
            }
        }, 'json');
    }

    function countIndustry() {
        $.post('/sys/index/countIndustry', function (res) {
            if (res.code == 0) {
                $("#countIndustry").html(res.data.nums);
            }
        }, 'json');
    }

    function countGuestBook() {
        $.post('/sys/index/countGuestBook', function (res) {
            if (res.code == 0) {
                $("#countGuestBook").html(res.data.nums);
            }
        }, 'json');
    }

    function usedSpace(params) {
        $.post('/sys/index/usedspace', function (res) {
            if (res.code == 0) {
                $("#spaceInfo").html(res.data.size);
            }
        }, 'json');
    }

    function clearCache() {
        $("#spaceInfo").html('<img src="/static/images/loading.gif" alt="正在载入" class="mid"> Loading...');
        $.post('/sys/index/clearcache', function (res) {
            if (res.code == 0) {
                layer.msg('清除成功', {
                    icon: 1,
                    time: 1000
                });
                usedSpace();
            }
        }, 'json');
    }

    /**
     * 新增快捷方式
     */
    function addButton() {
        $('#dialog').show();
    }
    function f_cancel() {
        $('#dialog').hide();
    }
    function saveIndexButton() {
        var data = $("#form-save").serializeArray();
        $.ajax({
            type: 'POST',
            url: '{:url("/sys/index/saveIndexButton")}',
            data: data,
            dataType: 'json',
            success: function (res) {
                // console.log(res);
                if (res.code == 0) {
                    layer.msg(res.msg, { icon: 1, time: 500 }, function () {
                        window.location.reload();
                    });
                } else {
                    layer.msg(res.msg, {
                        icon: 5,
                        time: 1000
                    });
                    return false;
                }
            }
        })
    }
</script>
<!--请在上方写此页面业务相关的脚本-->